package com.wanghuadi.beans;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.wanghuadi.common.utils.DateUtil;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
public class Student {

  private Integer id;
  private String sno;
  private String name;
  private Gender gender;
  private Date birthday;
  private Category category;
  private Subject subject;
  private String school;
  private Integer tid;
  private String tname;
  private Integer score;
  private Integer age;

  @DateTimeFormat(pattern = "yyyy-MM-dd")
  public void setBirthday(Date birthday) {
    this.age = DateUtil.getAge(birthday);
    this.birthday = birthday;
  }

  @JsonFormat(pattern = "yyyy-MM-dd")
  public Date getBirthday() {
    return birthday;
  }
}
